--Execute as OE
--- cre_func.sql

--- Create a function that populates the cache

CREATE OR REPLACE FUNCTION ORD_COUNT(cust_no number)
RETURN NUMBER
RESULT_CACHE RELIES_ON (orders)
IS
 V_COUNT NUMBER;
BEGIN
 SELECT COUNT(*) INTO V_COUNT
 FROM orders
 WHERE customer_id = cust_no;

 return v_count;
end;
/ 
